// $Id: HtmlUtils.java 2 2012-02-07 16:21:11Z diblikp@gmail.com $
package cz.pd.hamrsport.utils;

import java.io.StringReader;
import java.io.StringWriter;
import org.dom4j.Document;
import org.dom4j.io.DOMReader;
import org.w3c.tidy.Tidy;

/**
 * 
 * @author diblik
 * @version $Revision: 2 $
 */
public class HtmlUtils {

  public static Document HTMLtoXHTMLtoDOM4J(String html) {
    Tidy tidy = new Tidy(); // obtain a new Tidy instance
    tidy.setXHTML(true); // set desired config options using tidy setters
    StringWriter stringWriter = new StringWriter();
    org.w3c.dom.Document parseDOM = tidy.parseDOM(new StringReader(html), stringWriter);
    DOMReader reader = new DOMReader();
    Document document = reader.read(parseDOM);
    return document;
  }
}
